<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>动态生成二维码</title>
</head>
<body>
<div>
    请输入内容:<input type="text" id="content" name="content"/><br/>
    <input type="button" id="btn0" value="生成二维码方式〇"/>
    <input type="button" id="btn1" value="生成二维码方式一"/>
    <input type="button" id="btn2" value="生成二维码方式二"/>
    <input type="button" id="btn3" value="生成二维码方式三"/>
</div>
<hr/>
<img src="" alt="">
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script>

    $(function(){



        $("#content").keyup(function(event){
          if(event.keyCode ==13){
            var $content = $("#content").val();
            $("img").attr("src", "http://127.0.0.1:8880/qrtool2?content=" + $content);
          }
        });



        $("#btn0").click(function (){
            var $content = $("#content").val();
            $("img").attr("src", "http://127.0.0.1:8880/qrtool0?content=" + $content);
        });

        $("#btn1").click(function(){
            var $content = $("#content").val();
            $.ajax({
                type:"get",
                url:"http://127.0.0.1:8880/qrtool1?content="+$content,
                success:function(data){
                    $("img").attr("src", data)
                },
                error:function(xhr){
                    console.log(xhr.status);
                }
            });
        });

        $("#btn2").click(function(){
            var $content = $("#content").val();
            $("img").attr("src", "http://127.0.0.1:8880/qrtool2?content=" + $content);
        });

        $("#btn3").click(function(){
            var $content = $("#content").val();
            $("img").attr("src", "https://api.itmojun.com/qr?text=" + $content);
        });
    })


</script>
</body>
</html>